﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Common.Localization;

namespace UI
{
    public partial class NavigationPanel : UserControl, ILocalizable
    {
        public NavigationPanel()
        {
            InitializeComponent();
        }

        public event EventHandler DateTimeChanged;

        public void Localize()
        {
            
        }

        public void SetDateTime(DateTime dt)
        {
            this.dateTimePicker1.Value = dt;
            string s = "";
            s += dt.Hour.ToString().PadLeft(2, '0') + ":";
            s += dt.Minute.ToString().PadLeft(2, '0') + ":";
            s += dt.Second.ToString().PadLeft(2, '0') + ":";
            this.timeTextBox.Text = s;
        }

        public DateTime GetCurrtenDateTime()
        {
            int hour = int.Parse(this.timeTextBox.Text.Substring(0, 2));
            int minute = int.Parse(this.timeTextBox.Text.Substring(3, 2));
            int sec = int.Parse(this.timeTextBox.Text.Substring(6, 2));
            DateTime d = new DateTime(this.dateTimePicker1.Value.Year, this.dateTimePicker1.Value.Month,
                                      this.dateTimePicker1.Value.Day, hour, minute, sec);
            return d;
        }

        private void OnDateTimeChanged()
        {
            if (this.DateTimeChanged != null)
            {
                this.DateTimeChanged(this, null);
            }
        }

        private void NavigateButtonClick(object sender, EventArgs e)
        {
            this.OnDateTimeChanged();
        }
    }
}
